package com.nsyue.auth.domain.provider;

import com.nsyue.auth.domain.granter.PlatformAuthenticationToken;
import com.nsyue.auth.service.UserService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;

@Getter
@Setter
public class PlatformAuthenticationProvider implements AuthenticationProvider {

    private UserService userService;

    @Override
    public Authentication authenticate(Authentication authentication) {
        PlatformAuthenticationToken authenticationToken = (PlatformAuthenticationToken) authentication;
        //todo 自定义判断用户是否合法
        return authenticationToken;
    }

    /**
     * 是否可以提供输入UsernamePasswordAuthenticationToken类型的认证服务
     * @param authentication
     * @return
     */
    @Override
    public boolean supports(Class<?> authentication) {
        return PlatformAuthenticationToken.class.isAssignableFrom(authentication);
    }

}